//
//  SLDemo_MJRefreshController.m
//  Objective-C
//
//  Created by S_Line on 2018/8/30.
//  Copyright © 2018年 S_Line. All rights reserved.
//

#import "SLDemo_MJRefreshController.h"

#import "MJRefresh.h"

@interface SLDemo_MJRefreshController ()

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topConstraints;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraints;

@end

@implementation SLDemo_MJRefreshController

- (void)initNavBar {
    self.navTitle = @"MJRefresh";
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initNavBar];
    
    [self initView];
}

- (void)initView {
    self.topConstraints.constant = kNavigationBarHeight;
    self.bottomConstraints.constant = kSafeBottomMargin;
    
    self.scrollView.mj_header = [[MJRefreshGifHeader alloc] init];
    __weak typeof(self) weakself = self;
    self.scrollView.mj_header.refreshingBlock = ^{
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [weakself.scrollView.mj_header endRefreshing];
        });
    };
    [self.scrollView.mj_header beginRefreshing];
}

@end
